<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<include file="public:meta" />
		<link href="../public/css/company/common.css" rel="stylesheet" type="text/css" />
		<link href="../public/css/company/company_user.css" rel="stylesheet" type="text/css" />
		<link href="../public/css/company/company_ajax_dialog.css" rel="stylesheet" type="text/css" />
		<script src="../public/js/company/jquery.common.js" type="text/javascript" language="javascript"></script>
	</head>
	<body>
		<include file="index_header" />
		<div class="user_main">
			<div class="mleft">
				<include file="left_user" /> </div>
			<div class="mright">
				<div class="user_pagetitle">
					<div class="pat_l">企业认证</div>
					<div class="clear"></div>
				</div>
				<div class="user_tip w680">
					<div class="tiptit">小提示</div>
					<div class="tiptxt link_blue">
					我们强烈建议您认证企业营业执照，因为求职者更信任认证过的企业。
					</div>
				</div>
				<if condition="$Think.get.anew eq 1 or $company_profile['audit'] eq '0'">
					<!--提交表单-->
					<div class="plan default">
						<span class="s1">1 提交营业执照</span>
						<span class="s2">2 等待审核</span>
						<span class="s3">3 审核结果</span>
						<div class="clear"></div>
					</div>
					<div class="authentication">
						<form id="authentication_form" action="{:U('company/com_auth')}" method="post">
							<div class="mb16 J_validate_group">
								<div class="key">企业全称：</div>
								<div class="val">
									<input name="companyname" id="companyname" type="text" class="input_245_34" value="{$company_profile.companyname}">
								</div>
								<div class="tip_box J_showtip_box"></div>
								<div class="clear"></div>
							</div>
							<div class="mb40 J_validate_group">
								<div class="key">上传营业执照：</div>
								<div id="J_imgWrap" class="val">
									<div class="imgs">
										<img src="">
										<a href="javascript:;" class="J_del del"></a>
									</div>
									<div class="J_tipWrap tipWrap">
										<div class="tipor">图片需清晰：注册号、企业名称、法人代表、年检章等需清晰可辨</div>
									</div>
									<div class="fileWrap">
										<input id="certificate_img" name="certificate_img" type="file" class="" value="添加照片">
										最大支持{$max_size}，支持jpg/gif/png格式
									</div>
								</div>
								<input type="hidden" id="certificate_img_up" name="certificate_img_up" value="">
								<div class="tip_box pl0 J_showtip_box"></div>
								<div class="clear"></div>
							</div>
							<div class="mb16">
								<div class="key">&nbsp;</div>
								<div class="val">
									<input type="submit" id="J_submit" class="btn_blue J_hoverbut btn_115_38" value="提 交">
								</div>
								<div class="clear"></div>
							</div>
						</form>
					</div>
				<else/>
					<switch name="company_profile['audit']">
						<case value="1">
							<!--审核通过-->
							<div class="plan not">
								<span class="s1">1 提交营业执照</span>
								<span class="s2">2 等待审核</span>
								<span class="s3">3 审核结果</span>
								<div class="clear"></div>
							</div>
							<div class="authentication pass">
								<div class="planIco">审核通过</div>
								<div class="planTip">恭喜您，您提交的营业执照通过审核了！</div>
							</div>
						</case>
						<case value="2">
							<!--等待审核-->
							<div class="plan wait">
								<span class="s1">1 提交营业执照</span>
								<span class="s2">2 等待审核</span>
								<span class="s3">3 审核结果</span>
								<div class="clear"></div>
							</div>
							<div class="authentication wait">
								<div class="planIco">认证资料已提交，等待审核中</div>
								<div class="planTip">我们会在1个工作日内审核您的资料，请耐心等待！</div>
							</div>
						</case>
						<case value="3">
							<!--审核不通过-->
							<div class="plan not">
								<span class="s1">1 提交营业执照</span>
								<span class="s2">2 等待审核</span>
								<span class="s3">3 审核结果</span>
								<div class="clear"></div>
							</div>
							<div class="authentication not">
								<div class="planIco">审核不通过</div>
								<div class="planTip">
									您好，您提交的企业认证资料未通过审核，请<a class="font_blue" href="{:U('company/com_auth',array('anew'=>1))}">重新认证</a>
									<span>原因：您上传的营业执由于被多个帐号认证，请勿重复提交！</span>
								</div>
							</div>
						</case>
					</switch>
				</if>
			</div>
			<div class="clear"></div>
		</div>
	</body>
	<include file="index_footer" />
	<script src="../public/js/ajaxfileupload.js"></script>
	<script type="text/javascript" src="../public/js/jquery.validate.js"></script>
	<script src="../public/js/qscms.js"></script>
	<script type="text/javascript">
		$.upload('#certificate_img',{type:'certificate_img'},function(result){
			if(result.status == 1){
				$('#J_imgWrap').addClass('select').find('img').attr('src',result.data.url);
				$('input[name="certificate_img_up"]').val(result.data.img);
				$('#certificate_img_up').closest('.J_validate_group').find('.J_showtip_box').removeClass('pl0').html('<div class="ok"></div>');
			}else{
				alert(result.msg);
			}
		});
		$('.J_del').click(function(){
			$(this).prev('img').attr('src','');
			$('input[name="certificate_img_up"]').val('');
			$('#J_imgWrap').removeClass('select');
		});

		// 验证
		$("#authentication_form").validate({
	        rules: {
	            companyname: {
	                required: true
	            },
	            license: {
	                required: true
	            },
	            legal_person: {
	                required: true,
	                match: /^[\u4e00-\u9fa5]{2,20}$/
	            },
	            certificate_img_up: {
	                required: true
	            }
	        },
	        messages: {
	            companyname: {
	                required: '<div class="ftxt">请填写企业全称</div><div class="fimg"></div>'
	            },
	            license: {
	                required: '<div class="ftxt">请填写注册号</div><div class="fimg"></div>'
	            },
	            legal_person: {
	                required: '<div class="ftxt">请填写法人代表</div><div class="fimg"></div>',
	                match: '<div class="ftxt">法人代表格式不合法，请重新输入</div><div class="fimg"></div>'
	            },
	            certificate_img_up: {
	                required: '<div class="ftxt">请上传营业执照</div><div class="fimg"></div>'
	            }
	        },
	        errorClasses: {
	            companyname: {
	                required: 'tip err'
	            },
	            license: {
	                required: 'tip err'
	            },
	            legal_person: {
	                required: 'tip err',
	                match: 'tip err'
	            },
	            certificate_img_up: {
	                required: 'tip err'
	            }
	        },
	        errorElement: 'div',
	        errorPlacement: function(error, element) {console.log(element);
	            element.closest('.J_validate_group').find('.J_showtip_box').append(error);
	        },
	        success: function(label) {
	            label.append('<div class="ok"></div>');
	        }
	    });

	</script>
</html>